﻿window.onload = function () {
    var url = document.URL;
    //alert(url);
    var startNum, endNum, strUrl;
    startNum = url.indexOf("typeID=");
    strUrl = url.substr(startNum + 7, 1); //截取从指定位置开始的字符串长度

    if (strUrl == "2") {
        var rr1 = document.getElementById("oldbook").className = "p_on";
    }
    if (strUrl == "3") {
        var rr1 = document.getElementById("bike").className = "p_on";
    }
    if (strUrl == "4") {
        var rr1 = document.getElementById("life").className = "p_on";
    }
    if (strUrl == "5") {
        var rr1 = document.getElementById("wenju").className = "p_on";
    }
    if (strUrl == "6") {
        var rr1 = document.getElementById("phone").className = "p_on";
    }

	var width = document.getElementById('body').clientWidth;
	var linum = document.getElementsByTagName('li').length;
	console.log(linum);
	if(linum>0){
		for(var i = 0 ;i < linum ; i ++){
			document.getElementsByTagName('li')[i].style.width = width * 0.5 - 15 +'px';	
		}
	}
	if(linum>=1){
		document.getElementsByTagName('li')[0].style.left = 10 +'px';
		document.getElementsByTagName('li')[0].style.top = 10 +'px';
		var left = 10 + document.getElementsByTagName('li')[0].clientHeight;
	}
	if(linum>=2){
		document.getElementsByTagName('li')[1].style.right = 10 +'px';
		document.getElementsByTagName('li')[1].style.top = 10 +'px';
		var right =10 +	document.getElementsByTagName('li')[1].clientHeight;
	}
	if(linum>0){
		for(var i = 2 ;i < linum ; i ++){
			if(left <= right){
				document.getElementsByTagName('li')[i].style.left = 10 +'px';
				document.getElementsByTagName('li')[i].style.top = 10 + left +'px';
				left = left + 10 + document.getElementsByTagName('li')[i].clientHeight;
			}else{
				document.getElementsByTagName('li')[i].style.right = 10 +'px';
				document.getElementsByTagName('li')[i].style.top = 10 + right +'px';
				right = right + 10 + document.getElementsByTagName('li')[i].clientHeight;
			}
		}
		if(left < right)
			document.getElementById('showlist').style.height = right+ 10 +'px';
		else document.getElementById('showlist').style.height = left+ 10 +'px';
	}
	document.getElementById('found').onclick = function(){
		if(this.className == 'f_off'){
			this.className = 'f_on';
			document.getElementById('found_kind').style.display = 'block';
			document.getElementById('lock_screen').style.display = 'block';
		}else if(this.className == 'f_on'){
			this.className = 'f_off';
			document.getElementById('found_kind').style.display = 'none';
			document.getElementById('lock_screen').style.display = 'none';
		}
	}
	document.getElementById('lock_screen').style.height = document.documentElement.clientHeight + 'px';
	document.getElementById('lock_screen').onclick = function(){
		document.getElementById('found').className = 'f_off';
		document.getElementById('found_kind').style.display = 'none';
		document.getElementById('lock_screen').style.display = 'none';
	}
	
}